library(tidyverse)
## -- Attaching packages --------------------------------------- tidyverse 1.3.1 --
## v ggplot2 3.3.5 v purrr 0.3.4
## v tibble 3.1.1 v dplyr 1.0.6
## v tidyr 1.1.3 v stringr 1.4.0
## v readr 1.4.0 v forcats 0.5.1
## -- Conflicts ------------------------------------------ tidyverse_conflicts() --
## x dplyr::filter() masks stats::filter()
## x dplyr::lag() masks stats::lag()
library(plotly)
##
## Attaching package: 'plotly'
## The following object is masked from 'package:ggplot2':
##
## last_plot
## The following object is masked from 'package:stats':
##
## filter
## The following object is masked from 'package:graphics':
##
## layout
Visualize a “static” ggplot scatter plot between the Sepal variables with ggplot2.
iris %>%
ggplot(mapping = aes(x = Sepal.Length, y = Sepal.Width)) +
geom_point(size = 3.5) +
theme_bw()
Make an interactive version with ggplotly().
p <- iris %>%
ggplot(mapping = aes(x = Sepal.Length, y = Sepal.Width)) +
geom_point(size = 3.5) +
theme_bw()
fig <- ggplotly(p)
Visualize the interactive figure.
fig